var UserData = require('UserData')
cc.Class({
    extends: cc.Component,

    properties: {
        
    },
    
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        // mute Music

        this.node.getComponent(cc.AudioSource).mute = true
        this.node.getComponent(cc.AudioSource).volume = 1
        this.node.getComponent(cc.AudioSource).play()
     
        this.soundButton = this.node.getChildByName('音效按钮')
        this.musicButton = this.node.getChildByName('音乐按钮')


    },
    soundButtonCheck(target){
        if(target.isChecked){
            UserData.runtimeState.muteSound =false
        }else{
            UserData.runtimeState.muteSound = true
        }
    },
    musicButtonCheck(target){
        if(target.isChecked){
            UserData.runtimeState.muteMusic =false
        }else{
            UserData.runtimeState.muteMusic = true
        }
        if(!UserData.runtimeState.muteMusic){
            this.node.getComponent(cc.AudioSource).mute = false
            this.node.getComponent(cc.AudioSource).volume = 1
            //this.node.getComponent(cc.AudioSource).play()
        }else{
            this.node.getComponent(cc.AudioSource).mute = true
            this.node.getComponent(cc.AudioSource).volume = 1
        }   

    }
    // update (dt) {},
});
